package com.wxxymakers.cklabrecruit.mapper;

import com.wxxymakers.cklabrecruit.entity.EmailRecord;
import com.wxxymakers.cklabrecruit.entity.EmailRecordExample;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface EmailRecordMapper {
    long countByExample(EmailRecordExample example);

    int deleteByExample(EmailRecordExample example);

    @Delete({
        "delete from email_record",
        "where Id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into email_record (email_id, title, ",
        "status, pnum, datetime, ",
        "content)",
        "values (#{emailId,jdbcType=INTEGER}, #{title,jdbcType=VARCHAR}, ",
        "#{status,jdbcType=VARCHAR}, #{pnum,jdbcType=INTEGER}, #{datetime,jdbcType=TIMESTAMP}, ",
        "#{content,jdbcType=LONGVARCHAR})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Integer.class)
    int insert(EmailRecord record);

    int insertSelective(EmailRecord record);

    List<EmailRecord> selectByExampleWithBLOBs(EmailRecordExample example);

    List<EmailRecord> selectByExample(EmailRecordExample example);

    @Select({
        "select",
        "Id, email_id, title, status, pnum, datetime, content",
        "from email_record",
        "where Id = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("com.wxxymakers.cklabrecruit.mapper.EmailRecordMapper.ResultMapWithBLOBs")
    EmailRecord selectByPrimaryKey(Integer id);

    int updateByExampleSelective(@Param("record") EmailRecord record, @Param("example") EmailRecordExample example);

    int updateByExampleWithBLOBs(@Param("record") EmailRecord record, @Param("example") EmailRecordExample example);

    int updateByExample(@Param("record") EmailRecord record, @Param("example") EmailRecordExample example);

    int updateByPrimaryKeySelective(EmailRecord record);

    @Update({
        "update email_record",
        "set email_id = #{emailId,jdbcType=INTEGER},",
          "title = #{title,jdbcType=VARCHAR},",
          "status = #{status,jdbcType=VARCHAR},",
          "pnum = #{pnum,jdbcType=INTEGER},",
          "datetime = #{datetime,jdbcType=TIMESTAMP},",
          "content = #{content,jdbcType=LONGVARCHAR}",
        "where Id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKeyWithBLOBs(EmailRecord record);

    @Update({
        "update email_record",
        "set email_id = #{emailId,jdbcType=INTEGER},",
          "title = #{title,jdbcType=VARCHAR},",
          "status = #{status,jdbcType=VARCHAR},",
          "pnum = #{pnum,jdbcType=INTEGER},",
          "datetime = #{datetime,jdbcType=TIMESTAMP}",
        "where Id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(EmailRecord record);
}